/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package database;

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import java.util.HashMap;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 *
 * @author daolam
 */
public class MTJobSaveData implements Job{
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap data = context.getJobDetail().getJobDataMap();
        DB dbHandler = (DB)data.get("DBHANDLER");
        String theCollectionName = (String)data.get("COLLECTIONAME");
        HashMap<Short,String> theData = (HashMap<Short, String>)data.get("DATA");
        BasicDBObject document = new BasicDBObject(theData);
        DBCollection collection = dbHandler.getCollection(theCollectionName);
        collection.insert(document);
    }
}
